namespace IOPvsOOP.Chain.IF
{
    public class FooPool
    {
        private readonly Foo[] foos;
        private short index;
         
        public FooPool(Foo[] foos)
        {
            this.foos = foos;
        }

        public Foo Get()
        {
            var foo = foos[index];
            index++;
            if (index == foos.Length)
                index = 0;
            return foo;
        }
    }
}